package org.gesplan.entity;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author David
 */
@Entity
@Table(name = "location")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Location.findAll", query = "SELECT l FROM Location l"),
    @NamedQuery(name = "Location.findById", query = "SELECT l FROM Location l WHERE l.id = :id"),
    @NamedQuery(name = "Location.findByDescription", query = "SELECT l FROM Location l WHERE l.description = :description"),
    @NamedQuery(name = "Location.findByLocationParentId", query = "SELECT l FROM Location l WHERE l.locationParentId = :locationParentId")
})
public class Location implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "id")
    private String id;
    @Basic(optional = false)
    @Column(name = "description")
    private String description;
    @Column(name = "location_parent_id")
    private String locationParentId;
    @Column(name = "the_geom")
    private String theGeom;
    @Column(name = "comments")
    private String comments;
    @JoinColumn(name = "location_group_id", referencedColumnName = "id")
    @ManyToOne
    private LocationGroup locationGroupId;

    public Location() {
    }

    public Location(String id) {
        this.id = id;
    }

    public Location(String id, String description) {
        this.id = id;
        this.description = description;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getLocationParentId() {
        return locationParentId;
    }

    public void setLocationParentId(String locationParentId) {
        this.locationParentId = locationParentId;
    }

    public String getTheGeom() {
        return theGeom;
    }

    public void setTheGeom(String theGeom) {
        this.theGeom = theGeom;
    }

    public String getComments() {
        return comments;
    }

    public void setComments(String comments) {
        this.comments = comments;
    }

    public LocationGroup getLocationGroupId() {
        return locationGroupId;
    }

    public void setLocationGroupId(LocationGroup locationGroupId) {
        this.locationGroupId = locationGroupId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof Location)) {
            return false;
        }
        Location other = (Location) object;
        return (this.id != null || other.id == null) && (this.id == null || this.id.equals(other.id));
    }

    @Override
    public String toString() {
        return "org.gesplan.entity.Location[ id=" + id + " ]";
    }
    
    
}